﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SettingPanel : MonoBehaviour
{
    public static SettingPanel instance;
    private void Awake()
    {
        instance = this;
    }
    public static void Show()
    {
        if (instance)
        {
            instance.gameObject.SetActive(true);
        }
    }
    public static void Hide()
    {
        if (instance)
        {
            instance.gameObject.SetActive(false);
        }
    }
    private void Start()
    {
        SettingPanel.Hide();
    }

    public Rect rc_win;
    public GUIStyle windowStyle;

    private bool isSel1;
    private bool isSel2;
    public GUIStyle style;
    public GUIStyle cbtStyle;
    public GUIStyle label_style;
    public Rect rect1;
    public Rect rect2;
    public Rect rect3;

    public Rect rc_music_label;
    public Rect rc_audio_label;
    public Rect rc_music_volume;
    public Rect rc_audio_volume;
    private float musicVolume = 50f;
    private float audioVolume = 50f;

    private void DrawWindow(int id)
    {
        isSel1 = GUI.Toggle(rect1, isSel1, "音乐开关", style);
        isSel2 = GUI.Toggle(rect2, isSel2, "音效开关", style);

        GUI.Label(rc_music_label, "音乐音量", label_style);
        musicVolume = GUI.HorizontalSlider(rc_music_volume, musicVolume, 0, 100);
        GUI.Label(rc_audio_label, "音效音量", label_style);
        audioVolume = GUI.HorizontalSlider(rc_audio_volume, audioVolume, 0, 100);
        if (GUI.Button(rect3, "", cbtStyle))
        {
            SettingPanel.Hide();
        }
    }
    private void OnGUI()
    {
        GUI.ModalWindow(2, rc_win, DrawWindow, "", windowStyle);
    }
}
